package com.todo.strategy.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2024/5/5 20:33
 * @description
 */
@Getter
@AllArgsConstructor
public enum StrategyPaymentTypeEnum {

    EXCHANGE(1, "EXCHANGE", "兑换"),
    LIMITED_TIME_FREE(2, "LIMITED_TIME_FREE", "限时免费"),
    PURCHASE(3, "PURCHASE", "金额支付"),
    MEMBER_USED(4, "MEMBER_USED", "会员复用"),

            ;

    private static Map<Integer, StrategyPaymentTypeEnum> typeMap = Arrays
            .stream(StrategyPaymentTypeEnum.values())
            .collect(Collectors.toMap(StrategyPaymentTypeEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static StrategyPaymentTypeEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
